package com.own.component.common.model.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * ChildrenItemModel
 *
 * @author chenxueli
 * @date 2024-03-31 14:23:00
 */
@Getter
@Setter
@NoArgsConstructor
public class ChildrenItemModel<ITEM_TYPE, CHILD_TYPE> implements Serializable {

    @Schema(title = "项目内容")
    private ITEM_TYPE item;

    @Schema(title = "子节点")
    private List<CHILD_TYPE> children;

    public ChildrenItemModel(ITEM_TYPE item) {
        this.item = item;
        this.children = new ArrayList<>();
    }

    public ChildrenItemModel(ITEM_TYPE item, List<CHILD_TYPE> children) {
        this.item = item;
        this.children = children;
    }

    /**
     * 添加子节点
     *
     * @param item 子节点
     */
    public void add(CHILD_TYPE item) {
        this.children.add(item);
    }

}
